<?php
    if ($_FILES["file"]["error"] > 0)
  	{
  		echo "Error: " . $_FILES["file"]["error"] . "<br />";
  	}
  	else
  	{
  
    	include 'rest_client.php';
    	$path_temp = $_FILES["file"]["tmp_name"];
    	$lang = $_POST['lang'];
    	
    	$arr=array('lang'=>$lang,'image'=>"@$path_temp");
    	$url = "http://192.168.1.5:8080/TesseractAPI/tesseract";
    	$resp = RestClient::post($url,$arr);
  		$body = $resp->getResponse();
		
		$bodyDecode = json_decode($body,true);
		
		if(is_array($bodyDecode)) {
		    if($bodyDecode['error'])
				echo "Error : ".$bodyDecode['message'];
			else
				echo $bodyDecode['message'];
		} 
		else
			echo $body;
		
    }